//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ruoyi.live.platform.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.live.base.domain.SystemClassUserImportDetail;
import com.ruoyi.live.base.mapper.SystemClassUserImportDetailMapper;
import com.ruoyi.live.tool.commons.ICommons;
import com.ruoyi.live.tool.commons.IConvert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemClassUserImportDetailService {
    private static final Logger log = LoggerFactory.getLogger(SystemClassUserImportDetailService.class);
    @Autowired
    SystemClassUserImportDetailMapper dao;

    public SystemClassUserImportDetailService() {
    }

    public void addSystemClassUserImportDetail(SystemClassUserImportDetail entity) throws Exception {
        try {
            entity.setState(1);
            this.dao.insert(entity);
        } catch (Exception var3) {
            var3.printStackTrace();
            log.error("新增SystemClassUserImportDetail失败,编号SystemClassUserImportDetailService-addSystemClassUserImportDetail-1");
            throw new Exception("新增失败,编号SystemClassUserImportDetailService-addSystemClassUserImportDetail-1");
        }
    }

    public void updateSystemClassUserImportDetail(SystemClassUserImportDetail entity) throws Exception {
        try {
            this.dao.updateById(entity);
        } catch (Exception var3) {
            var3.printStackTrace();
            log.error("更新SystemClassUserImportDetail失败,编号SystemClassUserImportDetailService-updateSystemClassUserImportDetail-1,id:{}", entity.getId());
            throw new Exception("更新失败,编号SystemClassUserImportDetailService-updateSystemClassUserImportDetail-1");
        }
    }

    public SystemClassUserImportDetail getSystemClassUserImportDetail(Long id) {
        return (SystemClassUserImportDetail)this.dao.selectById(id);
    }

    public int deleteSystemClassUserImportDetail(String[] ids) throws Exception {
        if (ids.length == 0) {
            throw new Exception("请选择要删除的数据,编号SystemClassUserImportDetailService-deleteSystemClassUserImportDetail-1");
        } else {
            try {
                int count = 0;

                for(int i = 0; i < ids.length; ++i) {
                    if (!ICommons.isNullOrEmpty(ids[i])) {
                        count += this.dao.deleteById(IConvert.string2long(ids[i]));
                    }
                }

                return count;
            } catch (Exception var4) {
                var4.printStackTrace();
                log.error("删除SystemClassUserImportDetail失败,编号SystemClassUserImportDetailService-deleteSystemClassUserImportDetail-2,ids:{}", ids.toString());
                throw new Exception("删除的数据失败,编号SystemClassUserImportDetailService-deleteSystemClassUserImportDetail-2");
            }
        }
    }

    public List<SystemClassUserImportDetail> query(SystemClassUserImportDetail entity) {
        QueryWrapper<SystemClassUserImportDetail> wrapper = (QueryWrapper)((QueryWrapper)((QueryWrapper)((QueryWrapper)((QueryWrapper)((QueryWrapper)((QueryWrapper)((QueryWrapper)((QueryWrapper)((QueryWrapper)(new QueryWrapper()).eq(!ICommons.isNullOrEmpty(entity.getId()), "id", entity.getId())).eq(!ICommons.isNullOrEmpty(entity.getImportId()), "import_id", entity.getImportId())).eq(!ICommons.isNullOrEmpty(entity.getState()), "state", entity.getState())).like(!ICommons.isNullOrEmpty(entity.getBecause()), "because", entity.getBecause())).like(!ICommons.isNullOrEmpty(entity.getUserLoginName()), "user_login_name", entity.getUserLoginName())).like(!ICommons.isNullOrEmpty(entity.getUserRealName()), "user_real_name", entity.getUserRealName())).eq(!ICommons.isNullOrEmpty(entity.getUserSex()), "user_sex", entity.getUserSex())).like(!ICommons.isNullOrEmpty(entity.getUserPassword()), "user_password", entity.getUserPassword())).like(!ICommons.isNullOrEmpty(entity.getUserCellphone()), "user_cellphone", entity.getUserCellphone())).orderByDesc("state");
        return this.dao.selectList(wrapper);
    }
}
